package com.lcpress;

import java.util.TimeZone;

import javax.servlet.MultipartConfigElement;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.util.unit.DataSize;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@SpringBootApplication
@MapperScan(basePackages = "com.lcpress.mapper")
public class LcPressApplication {

	public static void main(String[] args) {
		//TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
		SpringApplication.run(LcPressApplication.class, args);
	}
	
	//修改tomcat文件上传大小限制配置
	@Bean
	public MultipartConfigElement multipartConfigElement() {
		MultipartConfigFactory factory = new MultipartConfigFactory();
		// 单个数据大小
		factory.setMaxFileSize(DataSize.ofMegabytes(10)); // KB,MB
		/// 总上传数据大小
		factory.setMaxRequestSize(DataSize.ofGigabytes(1));
		return factory.createMultipartConfig();
	}
	
	@RequestMapping(value = "/")
	public String user_index() {
		return "index";
	}
	
	@RequestMapping(value = "/admin")
	public String admin_index() {
		return "admin/admin_index";
	}
}
